<?php

require_once("../fachadasBD/MiniperfilMapper.php");

class MiniPerfil{

  private $usrname;
  private $email;
  private $nombre;
  private $apellido;
  private $foto;

  public function setUsername($val){
    $this->usrname = $val;
  }

  public function setEmail($val){
    $this->email = $val;
  }

  public function setNombre($val){
    $this->nombre = $val;
  }

  public function setApellido($val){
    $this->apellido = $val;
  }

  public function setFoto($val){
    $this->foto = $val;
  }

  public function getUsername(){
    return $this->usrname;
  }

  public function getEmail(){
    return $this->email;
  }

  public function getNombre(){
    return $this->nombre;
  }

  public function getApellido(){
    return $this->apellido;
  }

  public function getFoto(){
    return $this->foto;
  }

  public function setall($assoc){
    $this->usrname = $assoc["usrname"];
    $this->email = $assoc["email"];
    $this->nombre = $assoc["nombre"];
    $this->apellido = $assoc["apellido"];
    $this->foto = $assoc["foto"];
  }

  public function equals($P1,$P2){
    if($P1->getUsername() == $P2->getUsername()){
      return True;
    }else{
      return False;
    }
  }

  public function insert($array,$perfil){
    $bool=True;
    foreach ($array as $elem){
      if (MiniPerfil::equals($elem,$perfil)){
        $bool=False;
      }
    }
    if($bool){
      $array[]=$perfil;
    }
    return $array;
  }

  public function getall($string){

    $pMapper = MiniperfilMapper::getInstance();
    $resultado = $pMapper -> buscadorperfil($string);
    $CMinis= array();
    foreach ($resultado as $sqlr){
      if ($sqlr!=FALSE){

        while ($sqlsal0 = mysql_fetch_assoc($sqlr)){
          $mPerfil = new MiniPerfil();
          $mPerfil->setall($sqlsal0);
          $CMinis= MiniPerfil::insert($CMinis,$mPerfil);
        }
      }
    }
    return $CMinis;
  }
}


?>